// 首页
// https://www.naxiang.xyz:20003/

// 登录
// https://www.naxiang.xyz:20003/login

// 接单
// https://www.naxiang.xyz:20003/v2/task/list


let token = Android.getMap("token")
localStorage.setItem("token", token)


function getAndroidToken() {
    let token = localStorage.getItem("token").replace(/^"|"$/g, '');
    return token
}
getAndroidToken()



function getParameterHandler() {
    let headers = {
        "x-token": parameter.getMap("token")
    }
    let body = {}
    let strUrl = `?page=1&size=20&type=1`
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "json",
        requestType: "GET",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()


function getResponse() {
    let res = response.getMap("res")
    let code = "500"
    let message = "接单中"
    let dataKey = ""
    let dataValue = ""

    res = JSON.parse(res)
    if (res["code"] == 200 && res["data"]) {
        code = "200"
        message = "接单成功，请尽快完成"
    } else if (res["code"] == 200 && !res["data"]) {
        code = "500"
        message = "接单中..."
    } else {
        code = "300"
        message = res["message"]
    }

    return {
        code: code,
        message: message,
        dataKey: dataKey,
        dataValue: dataValue
    }
}
getResponse()